﻿using System;
using System.Globalization;
using Stimulus360.Models.Data;
using System.Collections.Generic;

namespace Stimulus360.Tests.Repositories
{
    /// <summary>
    ///     This class is used to create instances of the Idea and Project entity in the Stimulus 360 Database
    ///     for testing purposes.
    /// </summary>
    class FakeData
    {

        /// <summary>
        ///     Method returns a List of ideas for testing CRUD operations on the idea entity
        /// </summary>
        /// <returns>
        ///     List of ideas
        /// </returns>
        public static List<Idea> CreateIdeas()
        {

            List<Idea> ideaList = new List<Idea>();
            for (int i = 1; i <=20; i++)
            {
                Idea idea = new Idea();
                idea.IdeaId = i;
                idea.Title = "Test Idea " + i.ToString(CultureInfo.CurrentCulture);
                idea.Description = "This is test description";
                idea.SubmittedBy = "Admin";
                idea.InvestmentCategory = new InvestmentCategory { Category = "Water", CategoryId =1 };
                idea.Status = (byte)IdeaStatus.Accepted ;
                ideaList.Add(idea);
            }
            //Change the title to match test case testing "FindIdeaBySearchString"
            ideaList[19].Title = "Child Welfare";
            return ideaList;
        }

        /// <summary>
        ///     Method to create a new Idea 
        /// </summary>
        /// <returns>
        ///     Newly created idea
        /// </returns>
        public static Idea CreateIdea()
        {
            Idea idea = new Idea();
            idea.Status = (byte)IdeaStatus.Accepted ;
            idea.Title = "Test Idea";
            idea.Description = "This is a test case generated idea";
            idea.DateSubmitted =  DateTime.Now ;
            idea.SubmittedBy = "Admin";
            idea.InvestmentCategory = new InvestmentCategory{CategoryId =1};
            return idea;
        }


        /// <summary>
        ///     Creates an idea with an Invalid Investment Category
        /// </summary>
        /// <returns>
        ///     Returns an idea with an Invalid Investment Category
        /// </returns>
        public static Idea CreateInvalidCategoryIdea()
        {
            Idea idea = new Idea();
            idea.Status = (byte)IdeaStatus.Accepted ;
            idea.Title = "Test Idea";
            idea.Description = "This is a test case generated idea";
            idea.DateSubmitted = DateTime.Now ;
            idea.SubmittedBy = "Admin";
            idea.InvestmentCategory = new InvestmentCategory();
            return idea;
        }
        
        /// <summary>
        ///    Method to create a List of Projects to test CRUD operations on the Project Entity
        /// </summary>
        /// <returns>
        ///     List of projects
        /// </returns>
        public static List<Project> CreateProjects()
        {
            List<Project> listProjects = new List<Project>();
            //Create 5 projects with investment category =Water
            for (int i= 1;i<=4;i++)
            {
                Project project = new Project();
                project.ProjectId = i;
                project.InvestmentCategory = new InvestmentCategory {Category = "Water", CategoryId = 1};
                project.Title = "Test Project " + i.ToString(CultureInfo.CurrentCulture);
                project.Description = "This is a test project";
                project.DateCreated = DateTime.Now;
                project.Status = (byte)ProjectStatus.InProgress;
                project.ProjectManager = "Admin";
                listProjects.Add(project);
            }
            //Create 25 projects with investment category= Air
            for (int i = 4; i <= 30; i++)
            {
                Project project = new Project();
                project.ProjectId = i;
                project.InvestmentCategory = new InvestmentCategory { Category = "Air", CategoryId = 2 };
                project.Title = "Test Project " + i.ToString(CultureInfo.CurrentCulture);
                project.Description = "This is a test project";
                project.DateCreated = DateTime.Now;
                project.Status = (byte)ProjectStatus.InProgress;
                project.ProjectManager = "Admin";
                listProjects.Add(project);
            }
            return listProjects;
        }
    }
}
